<?php
namespace database;
use sql\SqlExec;
/*
 * 
	更新记录：
		2016-07-31 创建
		2017-07-25 更新
*/
class DnFolder
{
	function __construct()
	{ 
	}

	function Clear()
	{
	    $se = new SqlExec();
	    $se->exec("down_files", "truncate table down_files", null, null, null);		
	}
	
	function all_file($id)
	{
	    $se = new SqlExec();
	    $data = $se->exec_arr("up6_files"
	        , "select f_id,f_nameLoc ,f_pathSvr ,f_pathRel ,f_lenSvr ,f_sizeLoc from up6_files where f_pidRoot='$id';"
	        , "f_id,f_nameLoc,f_pathSvr,f_pathRel,f_lenSvr,f_sizeLoc"
	        , "f_id,nameLoc,pathSvr,pathRel,lenSvr,sizeLoc");
		
	    return json_encode($data,JSON_UNESCAPED_SLASHES| JSON_UNESCAPED_UNICODE);
	}
	
	/**
	 * 获取指定目录下的所有子文件
	 */
	function childs($pidRoot)
	{
	    $se = new SqlExec();
	    $fs = $se->select("up6_files", 
			"f_id,f_nameLoc,f_pathSvr,f_pathRel,f_lenSvr,f_fastdfs_id,f_lenLocSec,f_encrypt,f_blockSize,f_minio_id", 
			array("f_pidRoot"=>$pidRoot));
	    
	    $childs = array();
        for($i=0,$l=count($fs);$i<$l;++$i)
        {
            $f = $fs[$i];
            $item = array("f_id"=>$f["f_id"],
					"nameLoc"=>$f["f_nameLoc"],
					"pathSvr"=>$f["f_pathSvr"],
					"pathRel"=>$f["f_pathRel"],
					"lenSvr"=>$f["f_lenSvr"],
					"fastdfs_id"=>$f["f_fastdfs_id"],
					"lenLocSec"=>$f["f_lenLocSec"],
					"encrypt"=>$f["f_encrypt"],
					"blockSize"=>$f["f_blockSize"],
					"minio_id"=>$f["f_minio_id"]);
            $childs[] = $item;            
        }     
	    
	    return json_encode($childs,JSON_UNESCAPED_SLASHES| JSON_UNESCAPED_UNICODE);
	}
}
?>